package com.icss.OA.controller;

import com.icss.OA.common.R;
import com.icss.OA.pojo.Car;
import com.icss.OA.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CarController {

    @Autowired
    CarService carService;

    @PostMapping("car.action")
    public R add(@RequestBody Car car) {

        carService.add(car);

        return R.success("添加成功");
    }
    @PutMapping("car.action")
    public R update(@RequestBody Car car) {

        carService.update(car);

        return R.success("修改成功");
    }

    @GetMapping("car.action")
    public R add() {

        List<Car> clist = carService.findAll();

        return R.success(clist);
    }

    @DeleteMapping("car.action/{carNos}")
    public R add(@PathVariable String[] carNos) {

       carService.removeCarByCarNo(carNos);

        return R.success("删除成果");
    }
}
